package com.farm.shiro.service;

import com.farm.common.service.IBaseService;
import com.farm.shiro.entity.Permission;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 权限 业务逻辑接口
 *
 * @author ctidy
 * @since 2021/1/7
 */
public interface IPermissionService extends IBaseService<Permission> {
    List<Permission> listByAccount(long id);

    List<Permission> listByAccount(String username);

    List<Permission> listByRole(long id);

    List<Permission> listByRole(String name);

    boolean needFilter(String requestAPI);

    boolean canAccessByAccount(String requestAPI, long id);

    boolean canAccessByAccount(String requestAPI, String username);

    Set<String> listAuthorizedUrlByAccount(long id);

    Set<String> listAuthorizedUrlByAccount(String username);

    Map<String, String> loadFilterChainDefinitionMap();

    void refreshPermissions(ShiroFilterFactoryBean shiroFilterFactoryBean, long roleId, boolean isRemoveSession) throws Exception;

    void refreshPermissionByRole(long roleId, boolean isRemoveSession);
}
